home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 March / macformat-022.iso / Shareware City / Developers / src / out-of-phase-102-c / OutOfPhase 1.02 Source / OutOfPhase Folder / Envelope.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-23  |  8.2 KB  |  209 lines  |  [TEXT/KAHL]

  1. /* Envelope.h */
  2.  
  3. #ifndef Included_Envelope_h
  4. #define Included_Envelope_h
  5.  
  6. /* Envelope module depends on */
  7. /* MiscInfo.h */
  8. /* Audit */
  9. /* Debug */
  10. /* Definitions */
  11. /* Memory */
  12. /* Frequency */
  13.  
  14. /* this type is made so it can be changed */
  15. typedef float EnvNumberType;
  16.  
  17. /* possible patterns of the envelope transition */
  18. typedef enum
  19.     {
  20.         eEnvelopeLinearInAmplitude EXECUTE(= -13241),
  21.         eEnvelopeLinearInDecibels
  22.     } EnvTransTypes;
  23.  
  24. /* possible ways of obtaining the new target value */
  25. typedef enum
  26.     {
  27.         eEnvelopeTargetAbsolute EXECUTE(= -31125), /* target is new amplitude */
  28.         eEnvelopeTargetScaling /* target is current amplitude * scaling factor */
  29.     } EnvTargetTypes;
  30.  
  31. /* these are the kinds of sustain points there are */
  32. typedef enum
  33.     {
  34.         eEnvelopeSustainPointSkip EXECUTE(= -2341), /* hold this point, skip here on release */
  35.         eEnvelopeReleasePointSkip, /* don't hold this point, but skip here on release */
  36.         eEnvelopeSustainPointNoSkip, /* hold this point, but don't skip ahead on release */
  37.         eEnvelopeReleasePointNoSkip /* don't hold this point and don't skip ahead on release */
  38.     } SustainTypes;
  39.  
  40. #ifdef ShowMeEnvelopeRec
  41. typedef struct
  42.     {
  43.         /* transition duration (seconds) */
  44.         EnvNumberType                            Duration;
  45.         /* destination amplitude (0..1) or scaling factor */
  46.         EnvNumberType                            EndPoint;
  47.         /* transition type */
  48.         EnvTransTypes                            TransitionType;
  49.         /* way of deriving the target */
  50.         EnvTargetTypes                        TargetType;
  51.         /* adjustment factors */
  52.         EnvNumberType                            Accent1Amp;
  53.         EnvNumberType                            Accent2Amp;
  54.         EnvNumberType                            Accent3Amp;
  55.         EnvNumberType                            Accent4Amp;
  56.         EnvNumberType                            FrequencyAmpRolloff;
  57.         EnvNumberType                            FrequencyAmpNormalization;
  58.         EnvNumberType                            Accent1Rate;
  59.         EnvNumberType                            Accent2Rate;
  60.         EnvNumberType                            Accent3Rate;
  61.         EnvNumberType                            Accent4Rate;
  62.         EnvNumberType                            FrequencyRateRolloff;
  63.         EnvNumberType                            FrequencyRateNormalization;
  64.     } EnvStepRec;
  65. struct EnvelopeRec
  66.     {
  67.         /* number of envelope phases. 0 phases means the envelope produces constant value */
  68.         long                                            NumPhases;
  69.         /* list of definitions for each transition phase */
  70.         EnvStepRec*                                PhaseArray;
  71.         /* phase at which first sustain occurs. (released by key-up) */
  72.         /* if the value of this is N, then sustain will occur after phase N has */
  73.         /* completed.  if it is 0, then sustain will occur after phase 0 has completed. */
  74.         /* if it is -1, then sustain will not occur.  sustain may not be NumPhases since */
  75.         /* that would be the end of envelope and would be the same as final value hold. */
  76.         long                                            SustainPhase1;
  77.         SustainTypes                            SustainPhase1Type;
  78.         /* phase at which second sustain occurs. */
  79.         long                                            SustainPhase2;
  80.         SustainTypes                            SustainPhase2Type;
  81.         /* phase at which note-end sustain occurs */
  82.         long                                            SustainPhase3;
  83.         SustainTypes                            SustainPhase3Type;
  84.         /* phase used to align envelope timing with other envelopes */
  85.         long                                            Origin;
  86.  
  87.         EnvNumberType                            OverallScalingFactor;
  88.     };
  89. #else
  90. struct EnvelopeRec;
  91. #endif
  92. typedef struct EnvelopeRec EnvelopeRec;
  93.  
  94. /* create a new envelope record with nothing in it */
  95. EnvelopeRec*                        NewEnvelope(void);
  96.  
  97. /* dispose of an envelope record */
  98. void                                        DisposeEnvelope(EnvelopeRec* Envelope);
  99.  
  100. /* find out how many frames there are in the envelope */
  101. long                                        GetEnvelopeNumFrames(EnvelopeRec* Envelope);
  102.  
  103. /* set a release point.  -1 means this release point is ignored */
  104. void                                        EnvelopeSetReleasePoint1(EnvelopeRec* Envelope, long Release,
  105.                                                     SustainTypes ReleaseType);
  106. void                                        EnvelopeSetReleasePoint2(EnvelopeRec* Envelope, long Release,
  107.                                                     SustainTypes ReleaseType);
  108. void                                        EnvelopeSetReleasePoint3(EnvelopeRec* Envelope, long Release,
  109.                                                     SustainTypes ReleaseType);
  110.  
  111. /* get the value of a release point */
  112. long                                        GetEnvelopeReleasePoint1(EnvelopeRec* Envelope);
  113. long                                        GetEnvelopeReleasePoint2(EnvelopeRec* Envelope);
  114. long                                        GetEnvelopeReleasePoint3(EnvelopeRec* Envelope);
  115.  
  116. /* get the release point type */
  117. SustainTypes                        GetEnvelopeReleaseType1(EnvelopeRec* Envelope);
  118. SustainTypes                        GetEnvelopeReleaseType2(EnvelopeRec* Envelope);
  119. SustainTypes                        GetEnvelopeReleaseType3(EnvelopeRec* Envelope);
  120.  
  121. /* set the origin of the envelope */
  122. void                                        EnvelopeSetOrigin(EnvelopeRec* Envelope, long Origin);
  123.  
  124. /* get the origin from the envelope */
  125. long                                        GetEnvelopeOrigin(EnvelopeRec* Envelope);
  126.  
  127. /* set the value of an adjustment */
  128. void                                        EnvelopeSetAccent1Amp(EnvelopeRec* Envelope,
  129.                                                     double Val, long Phase);
  130. void                                        EnvelopeSetAccent2Amp(EnvelopeRec* Envelope,
  131.                                                     double Val, long Phase);
  132. void                                        EnvelopeSetAccent3Amp(EnvelopeRec* Envelope,
  133.                                                     double Val, long Phase);
  134. void                                        EnvelopeSetAccent4Amp(EnvelopeRec* Envelope,
  135.                                                     double Val, long Phase);
  136. void                                        EnvelopeSetFreqAmpRolloff(EnvelopeRec* Envelope,
  137.                                                     double Val, long Phase);
  138. void                                        EnvelopeSetFreqAmpNormalization(EnvelopeRec* Envelope,
  139.                                                     double Val, long Phase);
  140. void                                        EnvelopeSetAccent1Rate(EnvelopeRec* Envelope,
  141.                                                     double Val, long Phase);
  142. void                                        EnvelopeSetAccent2Rate(EnvelopeRec* Envelope,
  143.                                                     double Val, long Phase);
  144. void                                        EnvelopeSetAccent3Rate(EnvelopeRec* Envelope,
  145.                                                     double Val, long Phase);
  146. void                                        EnvelopeSetAccent4Rate(EnvelopeRec* Envelope,
  147.                                                     double Val, long Phase);
  148. void                                        EnvelopeSetFreqRateRolloff(EnvelopeRec* Envelope,
  149.                                                     double Val, long Phase);
  150. void                                        EnvelopeSetFreqRateNormalization(EnvelopeRec* Envelope,
  151.                                                     double Val, long Phase);
  152.  
  153. /* get the value of an adjustment */
  154. EnvNumberType                        GetEnvelopeAccent1Amp(EnvelopeRec* Envelope, long Phase);
  155. EnvNumberType                        GetEnvelopeAccent2Amp(EnvelopeRec* Envelope, long Phase);
  156. EnvNumberType                        GetEnvelopeAccent3Amp(EnvelopeRec* Envelope, long Phase);
  157. EnvNumberType                        GetEnvelopeAccent4Amp(EnvelopeRec* Envelope, long Phase);
  158. EnvNumberType                        GetEnvelopeFreqAmpRolloff(EnvelopeRec* Envelope, long Phase);
  159. EnvNumberType                        GetEnvelopeFreqAmpNormalization(EnvelopeRec* Envelope, long Phase);
  160. EnvNumberType                        GetEnvelopeAccent1Rate(EnvelopeRec* Envelope, long Phase);
  161. EnvNumberType                        GetEnvelopeAccent2Rate(EnvelopeRec* Envelope, long Phase);
  162. EnvNumberType                        GetEnvelopeAccent3Rate(EnvelopeRec* Envelope, long Phase);
  163. EnvNumberType                        GetEnvelopeAccent4Rate(EnvelopeRec* Envelope, long Phase);
  164. EnvNumberType                        GetEnvelopeFreqRateRolloff(EnvelopeRec* Envelope, long Phase);
  165. EnvNumberType                        GetEnvelopeFreqRateNormalization(EnvelopeRec* Envelope, long Phase);
  166.  
  167. /* set the overall amplitude scaling factor */
  168. void                                        EnvelopeSetOverallAmplitude(EnvelopeRec* Envelope,
  169.                                                     double OverallAmplitude);
  170.  
  171. /* get the overall amplitude */
  172. EnvNumberType                        GetEnvelopeOverallAmplitude(EnvelopeRec* Envelope);
  173.  
  174. /* insert a new phase at the specified position.  Values are undefined */
  175. MyBoolean                                EnvelopeInsertPhase(EnvelopeRec* Envelope, long Index);
  176.  
  177. /* delete a phase from the envelope */
  178. void                                        EnvelopeDeletePhase(EnvelopeRec* Envelope, long Index);
  179.  
  180. /* set a new value for the specified phase's duration */
  181. void                                        EnvelopeSetPhaseDuration(EnvelopeRec* Envelope, long Index,
  182.                                                     double Duration);
  183.  
  184. /* get the duration from the specified envelope position */
  185. EnvNumberType                        GetEnvelopePhaseDuration(EnvelopeRec* Envelope, long Index);
  186.  
  187. /* set a new value for the specified phase's ultimate value */
  188. void                                        EnvelopeSetPhaseFinalValue(EnvelopeRec* Envelope, long Index,
  189.                                                     double FinalValue);
  190.  
  191. /* get the phase's ultimate value */
  192. EnvNumberType                        GetEnvelopePhaseFinalValue(EnvelopeRec* Envelope, long Index);
  193.  
  194. /* set the value for a phase's transition type */
  195. void                                        EnvelopeSetPhaseTransitionType(EnvelopeRec* Envelope, long Index,
  196.                                                     EnvTransTypes TransitionType);
  197.  
  198. /* obtain the value in a phase's transition type */
  199. EnvTransTypes                        GetEnvelopePhaseTransitionType(EnvelopeRec* Envelope, long Index);
  200.  
  201. /* set the value for a phase's target type */
  202. void                                        EnvelopeSetPhaseTargetType(EnvelopeRec* Envelope, long Index,
  203.                                                     EnvTargetTypes TargetType);
  204.  
  205. /* get the target type for a phase */
  206. EnvTargetTypes                    GetEnvelopePhaseTargetType(EnvelopeRec* Envelope, long Index);
  207.  
  208. #endif
  209.